/**********************************************************
 * AccountingManagerAction.java
 * Created by ankur
 * Last modified Date: Aug 5, 2008 11:36:37 AM by ankur
 * Version : 0.1
 * Copyright (c) 2008 - 2008 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.printeverywhere.delegator.TransactionsServiceDelegator;
import com.printeverywhere.dto.GeneralOptions;
import com.printeverywhere.dto.ListingOptions;
import com.printeverywhere.dto.Transactions;
import com.printeverywhere.dto.User;
import com.printeverywhere.util.AdminConstants;
import com.printeverywhere.util.SearchCriteria;
import com.printeverywhere.util.SearchListCriteria;
import com.printeverywhere.util.SessionUtil;

/**
 * The Class AccountingManagerAction.
 */
public class PaymentActivityAction extends FrontBaseSupport implements ServletRequestAware{

	public PaymentActivityAction() {
		super(true, false);
		setMyAccount(true);
	}

	/** Logger for this class. */
	private static final Logger logger = Logger.getLogger(PaymentActivityAction.class);

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;
	private List<Transactions> transactionList = new ArrayList<Transactions>();
	private HttpServletRequest request;
	private SearchListCriteria searchCriteria = new SearchListCriteria();
	private User user;


	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}
		try{
			user = SessionUtil.getUser(request);

			searchCriteria.removeAllAttribute();
			searchCriteria.setAttribute(AdminConstants.USER,new Object[]{user, SearchListCriteria.EQ});
			transactionList = TransactionsServiceDelegator.getList(searchCriteria);
		}catch (Exception e) {
			addActionError("Sorry, can not proceed with payment activity. ");
			logger.error("Error in payment activity: "+ e.getMessage());
			return INPUT;
		}
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}

	public List<Transactions> getTransactionList() {
		return transactionList;
	}

	public void setTransactionList(List<Transactions> transactionList) {
		this.transactionList = transactionList;
	}

	public void setServletRequest(HttpServletRequest arg0) {
		request = arg0;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}